package com.itheima.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.itheima.pojo.Student;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * @author ch200
 * @description 针对表【student(学员表)】的数据库操作Mapper
 * @createDate 2025-03-11 20:34:52
 * @Entity com.itheima.pojo.Student
 */
@Mapper
public interface StudentMapper extends BaseMapper<Student> {
    //    根据班级id查询班级下的学员数量
    @Select("select count(*) from student where clazz_id = #{id}")
    Integer countByClazzId(Integer id);

    @Select("select s.*, c.name clazzName from student s left join clazz c on s.clazz_id = c.id ${ew.customSqlSegment}")
    Page<Student> page(Page<Student> p, @Param("ew") QueryWrapper<Student> wrapper);

    //    接口描述：统计学员的学历信息
    List<Map> getStutDegreeData();

    /**
     * 统计每一个班级的人数
     */
    List<Map<String, Object>> getStutCountData();
}




